<?php $this->load->view('layout/header');?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">我的账户</a></li>
            <li class="active"><a href="<?php echo site_url('accountinfo/storeInfo')?>">站点信息</a></li>
        </ul>
        <?php echo execute_alert_message();?>
        <div class="add-product">
            <form class="personal-form-validate form-horizontal" action="<?php echo site_url('accountinfo/editStoreInfo') ?>" method="post" enctype="multipart/form-data">
                <div class="fonter">基本信息</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>站点名称</label>
                    <div class="col-xs-4">
                        <input type="text" name="name" value="<?php echo $storeInfo->name;?>" class="form-control required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>公司名称</label>
                    <div class="col-xs-4">
                        <input type="text" name="company_name" value="<?php echo $storeInfo->company_name;?>" class="form-control required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>公司地址</label>
                    <div class="col-xs-5">
                        <input type="text" name="company_address" value="<?php echo $storeInfo->company_address;?>" class="form-control required"/>
                    </div>
                </div>
                <div class="fonter">业务信息</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>所属分类</label>
                    <div class="col-xs-3">
                        <select name="category_id" class="form-control">
                            <option value="0">请选择</option>
                            <?php foreach($category as $item):?>
                                <option value="<?php echo $item->id;?>" <?php if ($item->id == $storeInfo->category_id) :?> selected="selected"<?php endif;?>><?php echo $item->name;?></option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>主营业务</label>
                    <div class="col-xs-5">
                        <input type="text" name="main_business" value="<?php echo $storeInfo->main_business;?>" class="form-control required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>站点简介</label>
                    <div class="col-xs-10">
                        <textarea rows="20" name="detail" class="form-control required textarea-multipart-edit"><?php echo $storeInfo->detail;?></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>站点logo</label>
                    <div class="col-xs-8">
                        <div class="file-image" style="height: 80px;float: left;">
                            <img src="<?php echo $this->config->show_image_url($storeInfo->logo)?>" height="80">
                        </div>
                        <input type="file" name="logo">
                        <input type="hidden" name="logo" value="<?php echo $storeInfo->logo ?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>背景图片<br />(640×220)</label>
                    <div class="col-xs-8">
                        <div class="file-image" style="height: 160px;float: left;">
                            <img src="<?php echo $this->config->show_image_url($storeInfo->wap_image)?>" height="160">
                        </div>
                        <input type="file" name="wap_image">
                        <input type="hidden" name="wap_image" value="<?php echo $storeInfo->wap_image ?>">
                    </div>
                </div>
                <div class="fonter">客服信息</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">客服背景<br />(640×220)</label>
                    <div class="col-xs-8">
                        <div class="file-image" style="height: 160px;float: left;">
                            <img src="<?php echo $this->config->show_image_url($storeInfo->service_image)?>" height="160">
                        </div>
                        <input type="file" name="service_image">
                        <input type="hidden" name="service_image" value="<?php echo $storeInfo->service_image?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">客服电话</label>
                    <div class="col-xs-5">
                        <input type="text" name="service_mobile" value="<?php echo $storeInfo->service_mobile;?>" class="form-control allphone"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">客服微信<br />(二维码)</label>
                    <div class="col-xs-8">
                        <div class="file-image" style="height: 160px;float: left;">
                            <img src="<?php echo $this->config->show_image_url($storeInfo->service_wx)?>" height="160">
                        </div>
                        <input type="file" name="service_wx">
                        <input type="hidden" name="service_wx" value="<?php echo $storeInfo->service_wx?>">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">客服QQ</label>
                    <div class="col-xs-5">
                        <input type="text" name="service_qq" value="<?php echo $storeInfo->service_qq;?>" class="form-control" placeholder="多个QQ用,号隔开 （如 12365453,22363123）"/>
                    </div>
                </div>
                <div class="supplierlist-submit">
                    <button type="submit" class="btn btn-default">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->load->view('layout/footer');?>
<script type="text/javascript">
    if ($('textarea.textarea-multipart-edit').size() > 0) {
        KindEditor.create('textarea.textarea-multipart-edit', {  
            width : '100%',
            height :'400px'
       });
    }
    $('.personal-form-validate').validate({
        rules: {
            mobile_phone: {
                required: true,
                allphone:true,
                remote: {
                    url:hostUrl()+'/accountinfo/validateMobilePhone',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        mobile_phone:function(json) {
                            return $('input[name=mobile_phone]').val();
                        },
                        uid:function(json) {
                            return $('input[name=uid]').val();
                        }
                    }
                }
            }
        },
        messages: {
            mobile_phone: {
                required: '请输入您的手机号码',
                allphone: '电话号码格式错误',
                remote: '手机号码已注册'
            }
        }
    });
    $('.form-horizontal').on('change', 'input[type=file]', function (e) {
        var $this = $(this);
        upLoadImg(e.currentTarget.files[0], function (obj) {
            console.log(obj);
            $this.siblings('[type=hidden]').val(obj.save_path);
            $this.siblings('.file-image').children('img').attr('src', obj.file_url);
        });
    });
</script>
